// 创建数组 
var arr1 = ['a','b','c']
var arr2 = new Array(1, 2, 3);
var arr3 = [];
arr3[0] = 'a'
//字符串不能被改变，不能给其添加新的内容
var str3 = ''
str3[0] = 'a'
var arr4 = new Array()
arr4[0] = 'a'
arr4[2] = 'b'

//数组判断
var x = 1
typeof x
Array.isArray()

//数组添加
var arr5 = ['a','b']

arr5[2] = 'c'
arr5[3] = 'd'
//如果这个索引存在值怎会替换
arr5[1] = 'x'
//添加到数组的最后面
arr5[arr5.length] = 'x'
arr5[arr5.length] = 'y'

var arr6 = ['a','b']
arr6.push('h')
arr6.push('l')
arr6.push('o','x')

var arr7 = ['x','7']
var arr8 = ['a','b']
var arr9 = arr7.concat(arr8)
var arr10 = ['e','f']
//可以把...理解为打开[]
var arr11 = [...arr7,...arr8,...arr10]
// splice slice splite
//插入或者删除元素
//splice(location, count, items...)
var heros = ["露娜", "上官婉儿", "李白", "嬴政", "貂蝉", "兰陵王", "亚瑟"];
//删除李白
// heros.splice(2,1)
// "嬴政", "貂蝉"
// heros.splice(3,2)
// 删除之后再添加
// heros.splice(3,2,'项羽','后裔','钟馗')
//再索引为3的元素前面插入内容
// heros.splice(3,0,'鲁班7号')
var heros1 = heros
//浅拷贝
var heros2 = heros.slice()

var arr11 = [11, "b", 3, 2, "A", "a", "B"];
//排序会改变原素组，并返回原素组
var arr12 = arr11.sort()

var nums = [20,1,50, 8, 13, 30]; 
//数值降序排列
nums.sort(function(a,b){
    return b-a
})
//数值升序排列
nums.sort(function(x,y){
    return x-y
})


